package cc.mrbird.febs.cos.controller;


import cc.mrbird.febs.common.utils.R;
import cc.mrbird.febs.cos.entity.MailboxInfo;
import cc.mrbird.febs.cos.service.IMailboxInfoService;
import cc.mrbird.febs.cos.service.IMessageInfoService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * @author fanke
 */
@RestController
@RequestMapping("/cos/mailbox-info")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class MailboxInfoController {

    private final IMailboxInfoService mailboxInfoService;

    /**
     * 分页查询
     * @param page
     * @param mailboxInfo
     * @return
     */
    @GetMapping("/page")
    public R getBooKInfoByPage(Page page, MailboxInfo mailboxInfo) {
        return R.ok(mailboxInfoService.page(page, Wrappers.<MailboxInfo>lambdaQuery()
                .gt(mailboxInfo.getStartDate()!=null && mailboxInfo.getEndDate() != "",MailboxInfo::getSendDate,mailboxInfo.getStartDate())
                .lt(mailboxInfo.getEndDate()!=null && mailboxInfo.getEndDate() != "",MailboxInfo::getSendDate,mailboxInfo.getEndDate())
                .like(mailboxInfo.getSendName()!=null && mailboxInfo.getSendName() != "",MailboxInfo::getSendName,mailboxInfo.getSendName())
                .orderByDesc(MailboxInfo::getSendDate)));
    }

}
